package com.example.ffepeg.ffeAdder;

import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.ArrayList;
import java.util.List;

public class FfeDubbing {
    String url = "C:\\Users\\Administrator\\Desktop\\d4d312da-204e-4ea6-8ee5-8685b0812a0b.mp4";
    String path = "C:\\Users\\Administrator\\Desktop\\cd2d71d9-518e-4652-a0ca-0f633ed5ede8.wav";
    String outputFile = "D:\\javaXM\\FFEpeg\\src\\main\\resources\\out\\twoSixfiles00k.mp4";


    public static void main(String[] args) {
        try {
            String url = "https://pushimg.liecaizhijia.com/video/gen/2024-09-24/89a32ab1-3657-4e56-a83f-bda21593f817.mp4";
            Process process = Runtime.getRuntime().exec("ffprobe -i "+ url +" -show_entries format=duration -v quiet -of csv=\"p=0\"");
            java.util.Scanner scanner = new java.util.Scanner(process.getInputStream()).useDelimiter("\\A");
            String durationString = scanner.hasNext() ? scanner.next() : "";
            double durationInSeconds = Double.parseDouble(durationString);
            System.out.println("视频时长（秒）：" + durationInSeconds);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }


   /* public static void main(String[] args) {
        String input = "<speak>欢迎来到英雄联盟<break time='500ms'/>德玛西亚<break time='400ms'/>昂扬不灭<break time='500ms'/>提莫队长<break time='400ms'/>正在待命</speak>";
        Pattern pattern = Pattern.compile("time='(\\d+)ms'");
        Matcher matcher = pattern.matcher(input);

        List<Integer> msList = new ArrayList<>();
        while (matcher.find()) {
            msList.add(Integer.parseInt(matcher.group(1)));
        }
        int sum = 0;
        if (!msList.isEmpty()){
            for (Integer ms : msList) {
                sum += ms;
            }
        }
        System.out.println("数据和为: " + sum);
    }*/

}
